import random
import re


mac_list = []


# 生成MAC地址
def mac_make():
    while 1:
        last = ""
        for i in range(3):
            num = hex(random.randint(0, 255)).upper()
            if re.search('^[0-9]$|^[A-Z]$', num[2:]):
                last = last + f"-0{num[2:]}"
            else:
                last = last + f"-{num[2:]}"
        # 防止重复
        if f"01-AF-3B{last}" not in mac_list:
            mac_list.append(f"01-AF-3B{last}")
            break
    return mac_list


count = int(input("请输入需要的MAC地址数："))
with open('mac.txt', 'a+') as f:
    for i in range(count):
        f.write(f"{mac_make()[i]}\n")
print("添加完毕！")


